<?php
@$name=$_REQUEST["name"];
@$pwd=$_REQUEST["pwd"];
$pdo=new PDO("mysql:dbname=caipin;host=127.0.0.1;charset=UTF8","root","root");
$sql3=$pdo->prepare("select * from zhanghao  where login=:login;");
$sql3->execute(array("login" => $name));
$h=$sql3->fetch(PDO::FETCH_NAMED);
				
if(!is_null($name) && !is_null($pwd)){
    if($name==$h["login"] && $pwd==$h["password"]){
		 
		 session_start();

    $_SESSION["islogin"]=true;
        
		echo "登录成功";
		 header('Location:zhuohao.php');
    }else if($name!=$h["login"] && $pwd!=$h["password"]){
 ?>
	  <div class="row">
<div class="col-sm-offset-4 col-sm-8"style="width: 400px;margin: 20px 0 0px 445px">
	   <div class="alert alert-danger">
 <button class="close" data-dismiss="alert">
 <span>&times;</span>
 </button>
   用户名不存在
   </div>
 </div>
 </div>
		 <?php 
	}
		
	else{
      ?>
	  <div class="row" >
<div class="col-sm-offset-4 col-sm-8"style="width: 400px;margin: 20px 0 0px 445px">
	   <div class="alert alert-danger">
 <button class="close" data-dismiss="alert">
 <span>&times;</span>
 </button>
   密码错误
   </div>
 </div>
 </div>
		 <?php 
		
    }
}
?>
<html>
<head>
    <meta charset="UTF-8">
    <title>
        <?php
        echo "登录系统";
        ?>
    </title>
    <link type="text/css" rel="stylesheet" href="css/bootstrap.css">
    <link type="text/css" rel="stylesheet" href="css/bootstrap-theme.css">
    <script src="js/jQuery文件.js"></script>
    <script src="js/bootstrap.js"></script>
</head>

<body>
<div class="container">
<div class="row">
<div class="col-sm-offset-4 col-sm-8"style="width: 400px;margin-top: 20px">
        <div class="panel-group" >
            <div class="panel panel-primary">
                <div class="panel-heading"  >
                    <div class="panel-title"><span class="glyphicon glyphicon-glass">
				</span>	登录点餐系统</div>
</div>
                    <div class="panel-body">





 <form class="form-horizontal" method="post" action="diancanxitong.php" >
                    
                 <div class="form-group ">
                            <label for="userName" class="control-label col-sm-3">登录名:</label>
                            <div class="col-sm-9">
                                <input   placeholder="登录名" class="form-control" name="name">
                            </div>
                        </div>

						<div class="form-group ">
                            <label for="userName" class="control-label col-sm-3">密  码:</label>
                            <div class="col-sm-9">
                                <input  type="password" class="form-control" name="pwd"  placeholder="密码">
                            </div>
               
					</div>
                
				
				<div class="form-group">
                            <label for="userName" class="control-label col-sm-9"></label>
                            <div class="col-sm-3">
                            <button  class="btn btn-primary btn-block">登录</button>
                         
                       
                       
				
				</div>
				
				
				</div>
				
				</form>



                    </div>

            </div>

        </div>
		</div>
		</div>

</body>
</html>